﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Animation;
using Microsoft.Xna.Framework;

namespace MapLibrary.Players.CollisionResponse
{
    class SlowDownBehavior : CollisionBehavior
    {
        private float damping;
        private Sprite sprite;

        bool containedLastFrame;

        public SlowDownBehavior(Sprite toSlow, float damping)
        {
            this.sprite = toSlow;
            this.damping = damping;

            containedLastFrame = false;
        }

        public override void Update(bool contained)
        {
            if (contained)
            {
                if(!containedLastFrame)
                    sprite.Body.LinearDamping = damping + sprite.Body.LinearDamping;
                containedLastFrame = true;
            }
            else
            {
                if (containedLastFrame)
                    sprite.Body.LinearDamping = sprite.Body.LinearDamping - damping;

                containedLastFrame = false;
            }
        }
    }
}
